package org.bravof.differ.controller;

import lombok.extern.log4j.Log4j;
import org.bravof.differ.entity.result.DifferencePO;
import org.bravof.differ.query.ResultModel;
import org.bravof.differ.service.core.db2ja.DB2ModelService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * API
 */
@Log4j
@RestController
@RequestMapping("/api")
public class ApiController {
    @Resource
    private DB2ModelService db2ModelService;

    @RequestMapping("/tellDifference")
    public ResultModel<List<String>> tellDifference(String leftId, String rightId) {
        log.info("比对两库差异，左库Id -> " + leftId + ", 右库Id -> " + rightId);
        DifferencePO differencePO = db2ModelService.tellDifference(leftId, rightId);
        List<String> changeSql = differencePO.getChangeSql();
        ResultModel<List<String>> model = new ResultModel<>();
        model.setModel(changeSql);
        return model;
    }
}
